using Blog.Command.Extensions;
using Microsoft.OpenApi.Models;
using SqlSugar.IOC;

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.

builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen( c =>
c.SwaggerDoc("v1", new OpenApiInfo { Title = "Blog.JWT", Version = "v1" })
);

builder.Services.AddSqlSugar(new IocConfig()
{
    ConnectionString = builder.Configuration.GetSection("SqlConn").Value,
    DbType = IocDbType.SqlServer,
    IsAutoCloseConnection = true
});

builder.Services.ExtensionsIOC();

var app = builder.Build();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
    app.UseSwagger();
    app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "Blog.JWT v1"));
}

app.UseHttpsRedirection();

app.UseAuthorization();

app.MapControllers();

app.Run();
